{extend name="public/original" /}
{block name="title"}编辑权限{/block}
{block name="css"}
<style type="text/css">
  .layui-input-inline{width: 260px !important;}
</style>
{/block}
{block name="content"}
<div class="layui-form" lay-filter="filter-form-auth" id="form-auth" style="padding: 20px 30px 0 0;">
    <div class="layui-form-item">
      <label class="layui-form-label">权限名</label>
      <div class="layui-input-inline">
        <input type="text" name="authtitle" lay-verType="tips" lay-verify="required" placeholder="请输入权限名称" autocomplete="off" class="layui-input" value="{$info.title}" >
      </div>
    </div>
    <div class="layui-form-item">
      <label class="layui-form-label">权限类型</label>
      <div class="layui-input-inline">
        <select name="type" lay-verType="tips" lay-verify="required" lay-filter="typeSel" data-url="{:route('AuthSet/modsTree')}">
          <option value="">选择一个类型</option>
          <option value="1" {if $info.type==1}selected{/if} >模块</option>
          <option value="2" {if $info.type==2}selected{/if}>子模块</option> <!-- 一般用于左侧有三级菜单的情况 -->
          <option value="3" {if $info.type==3}selected{/if}>节点</option>
        </select>
      </div>
    </div>
    <div class="layui-form-item" id="fatherMod" style="display: none;">
      <label class="layui-form-label">所属上级</label>
      <div class="layui-input-inline">
        <select name="pId" class="fathersel" lay-verType="tips" lay-filter="fathersel" lay-verify="pidneed" lay-search>
          <option></option>
        </select>
      </div>
    </div>
    <div class="layui-form-item">
      <label class="layui-form-label">权限标识</label>
      <div class="layui-input-inline">
        <input type="text" name="authname"  placeholder="请输入标识" autocomplete="off" class="layui-input" value="{$info.name}" {if $info.name=='AuthSet/permissions'}disabled{/if}>
      </div>
    </div>
    {if $info.run_type==1}
    <div class="layui-form-item" id="menuCtl">
      <label class="layui-form-label">设为菜单</label>
      <div class="layui-input-inline">
        <input type="checkbox" lay-filter="menuSwt" name="is_menu" lay-skin="switch" lay-text="是|否" value="1" {$info.is_menu == 1 ? 'checked=""' : '' } {if $info.name=='AuthSet/permissions'}disabled{/if}>
      </div>
    </div>
    <div class="layui-form-item" id="iconCtl" {if $info.is_menu != 1}style="display: none;"{/if}>
      <label class="layui-form-label">图标</label>
      <div class="layui-input-block">
        <input type="text" id="iconPicker" lay-verify="Menu" lay-filter="iconPicker" name="icon" value="{$info.icon|default=' '}">
      </div>
    </div>
    <div class="layui-form-item" id="weight" {if $info.is_menu != 1}style="display: none;"{/if}>
      <label class="layui-form-label">权重</label>
      <div class="layui-input-inline">
        <input type="text" name="sorted" class="layui-input" value="{$info.sorted|default=0}" lay-verify="number">
      </div>
    </div>
    {else/}
    <div class="layui-form-item" id="logCtl">
      <label class="layui-form-label">记录日志</label>
      <div class="layui-input-inline">
        <input type="checkbox" name="is_log" lay-skin="switch" lay-text="是|否" value="1" {$info.is_logged == 1 ? 'checked=""' : '' }>
      </div>
      <div class="layui-form-mid layui-word-aux">请在需要记录日志的行为时再开启</div>
    </div>
    {/if}
    <div class="layui-form-item">
      <label class="layui-form-label">权限描述</label>
      <div class="layui-input-block" >
        <textarea placeholder="对权限的描述或者记录日志的行为描述" class="layui-textarea" name="desc" lay-verType="tips" lay-verify="descNeed">{$info.remark}</textarea>
      </div>
    </div>
    <div class="layui-form-item">
      <label class="layui-form-label">状态</label>
      <div class="layui-input-inline">
        <input type="checkbox" name="status" lay-skin="switch" lay-text="正常|关闭" value="1" {$info.status == 1 ? 'checked=""' : '' } {if $info.name=='AuthSet/permissions'}disabled{/if}>
      </div>
    </div>
    <div class="layui-form-item layui-hide">
      <input type="hidden" name="rule_id" value="{$info.id}">
      <input type="hidden" name="{:config('this.form_token')}" value="{:token()}" />
      <input type="button" lay-submit lay-filter="auth-submit" id="auth-submit" value="确认" data-url="{:route('AuthSet/editRule')}">
    </div>
  </div>
{/block}
{block name="footjs"}
<script id="treeMods" type="text/html">
  <option></option>
  {{# layui.each(d, function(i, t){ }}
    <option value="{{t.id}}" data-l="1" {{# if (t.id == {$info.pid}) { }}selected{{# } }}>{{t.title}} ({{t.name}})</option>
    {{# if(t.child){ }}
      {{# layui.each(t.child, function(ii, tt){ }}
        <option value="{{tt.id}}" data-l="2" {{# if (tt.id == {$info.pid}) { }}selected{{# } }}>└ {{tt.title}} ({{tt.name}})</option>
      {{# }); }}
    {{# } }}
  {{# }); }}
</script>
<script type="text/javascript" src="__STATIC__/mod/admin/authset/auth_edit.js" id="auth_edit" data-path="__JS__"></script>
{/block}